package com.zhj.interview;

/**
 * @author zhj
 */
public class Test09 {

    public static void main(String[] args) {
        int[] A = {2,3,1,1,4};
        System.out.println(canJump(A));
    }

    public static boolean canJump(int[] A) {
        int n = A.length;
        boolean[] f = new boolean[n];
        f[0] = true;

        for (int j = 1; j < n; j++) {
            f[j] = false;
            for (int i = 0; i < j; i++) {
                if (f[i] && i + A[i] >= j) {
                    f[j] = true;
                    break;
                }
            }
        }
        return f[n-1];
    }
}
